
package cn.jbolt.ai.resource.vdb.controller;

import cn.jbolt.ai.resource.vdb.entity.VDBResource;
import cn.jbolt.ai.resource.vdb.service.VDBResourceService;
import cn.jbolt.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * VDB资源管理
 */
@Controller
@ResponseBody
@RequestMapping("/VDBResource")
@Tag(name = "VDB资源管理Controller")
public class VDBResourceController {

    @Autowired
    private VDBResourceService vdbResourceService;

    @Operation(summary = "根据ID获取资源信息", description = "根据ID获取资源信息")
    @GetMapping("/getById/{id}")
    public Result getById(@PathVariable Long id) {
        return vdbResourceService.getResourceById(id);
    }

    @Operation(summary = "获取所有资源信息", description = "获取所有资源信息")
    @GetMapping("/list")
    public Result listByPage( Integer page,
                         Integer pageSize,
                         @RequestParam(required = false) String keywords) {
        return vdbResourceService.listByPage(page, pageSize, keywords);
    }

    @Operation(summary = "添加新的资源", description = "添加新的资源")
    @PostMapping("/add")
    public Result add(@RequestBody VDBResource resource) {
        return vdbResourceService.add(resource);
    }

    @Operation(summary = "更新资源信息", description = "更新资源信息")
    @PutMapping("/update")
    public Result update(@RequestBody VDBResource resource) {
        return vdbResourceService.update(resource);
    }

    @Operation(summary = "删除资源", description = "删除资源")
    @GetMapping("/del/{id}")
    public Result del(@PathVariable Long id) {
        return vdbResourceService.del(id);
    }

    @Operation(summary = "修改资源的启用状态", description = "修改资源的启用状态")
    @GetMapping("/toggleEnable/{id}")
    public Result toggleEnable(@PathVariable Long id) {
        return vdbResourceService.toggleEnable(id);
    }

    @Operation(summary = "获取VDB的类型的下拉选", description = "获取VDB的类型的下拉选")
    @GetMapping("/listAllEnabledType")
    public Result listAllEnabledType( ) {
        return vdbResourceService.listAllEnabledType();
    }
}
